<template>
	<view class="content">
        <uni-password :show="true" digits="6" @confirm="onConfirm">
        	请输入支付密码
        </uni-password>
		<view class="g-frame-mask" v-if="showPopup"></view>
		<view class="g-frame" v-if="showPopup">
			<view class="m-frame-header">
			    <view class="u-frame-title">提示</view>
			    <image class="u-frame-close" src="../../../static/icons/ydt/close.png" mode="widthFix" @tap="togglePopup"></image>
			</view>
			<view class="u-frame-cont">本次退取{{accountType}}数量: {{onLoadData.amount}}<br />请确认</view>
			<view class="m-frame-footer">
			    <view class="u-reset" @tap="togglePopup">取消</view>
			    <view class="u-confirm" @tap="toConfirm">确定</view>
			</view>
		</view>
		<view class="m-full-loading" v-if="showloading">
			<view class="m-loading">
				<image src="../../../static/images/loading.gif" mode="widthFix"></image>
			    <text>加载中</text>
			</view>
		</view>
	</view>
</template>

<script>
	import henglang from '@/common/common_zb.js'
	import md5 from '@/common/md5.js'
	export default {
		data() {
			return {
				onLoadData:{},
				showloading: false,
				showPopup: false,
				accountType: '',
				sendData:{
					amount:'',
					method:'',
					account:'',
					paypwd: '',
					code:'',
					state:''
				},
				password: ''
			}
		},
		onLoad(option) {
			this.onLoadData = option;
			
			this.sendData = {
				amount: option.amount,
				method: option.method,
				account: option.account,
				code: option.code,
				state: option.state
			}
			
			if(this.onLoadData.state == '5') {
				this.accountType = '寄存津贴';
			}else if(this.onLoadData.state == '4') {
				this.accountType = '保养津贴';
			}else{
				this.accountType = '代言得米';
			}
		},
		methods: {
			togglePopup() {
			    this.showPopup = !this.showPopup;
			},
			onConfirm(e) {
				this.showPopup = true;
				this.password = md5(e);
			},
			toConfirm() {
				let that = this;
				that.showPopup = false;
				that.showloading = true;
				that.sendData.paypwd = that.password;
				henglang.post('Agent_jewel/applyWithdraw',that.sendData,true,function(res){
					that.showloading = false;
					if(res.data.code == 0){
						henglang.showToast(res.data.msg,500);
						setTimeout(() => {
							uni.redirectTo({
								url:'/pages/jewel/agent_jewel/hl_takedeital'
							})
						}, 1000);
					}else if(res.data.code == -1){
						henglang.showToast(res.data.msg);
					}
				})
				
			}
		}
	}
</script>
<style>
	.content {
		text-align: center;
		height: 400upx;
	}
	.m-full-loading{
		background-color: transparent;
	}
	.m-loading{
		z-index: 21;
	}
	.g-frame {
	    width: 581upx;
	    background: #fff;
	    border-radius: 20upx;
	    position: fixed;
	    top: 50%;
	    overflow: hidden;
	    left: 50%;
		margin-top: -215upx;
		margin-left: -290upx;
		z-index: 12;
	}
	
	.g-frame-mask {
	    background: #000;
	    opacity: .5;
	    height: 100vh;
	    width: 100%;
	    position: fixed;
	    top: 0upx;
		z-index: 11;
	}
	
	.m-frame-header {
	    height: 110upx;
	    width: 100%;
	    background: #d71311;
	    border-top-right-radius: 20upx;
	    border-top-left-radius: 20upx;
		position: relative;
		margin-bottom: 35upx;
	}
	.u-frame-title {
	    width: 100%;
	    text-align: center;
	    color: #fff;
	    line-height: 110upx;
	    font-size: 32upx;
	}
	
	.u-frame-close {
	    width: 42upx;
	    height: 42upx;
	    background-size: 100%;
	    position: absolute;
	    top: 50%;
		margin-top: -21upx;
	    right: 32upx;
	}
	.u-frame-cont{
		text-align: center;
		font-size: 36upx;
		padding-bottom: 35upx;
		line-height: 60upx;
		width: 500upx;
		margin: 0 auto;
	}
	.m-frame-footer {
	    height: 100upx;
	    width: 100%;
	    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
		display: flex;
		align-items: center;
		margin-top: 20upx;
	}
	
	.m-frame-footer view {
		flex: 1;
	    line-height: 100upx;
	    text-align: center;
	    font-size: 32upx;
	}
	
	.u-reset {
	    color: #ff0000;
	    background: #fff;
	}
	
	.u-confirm {
	    background: #d71311;
	    color: #fff;
	    border-bottom-right-radius: 16upx;
	}
	
</style>
